'use strict';

/**
 * @description: delet tree node
 * @param origin 数据源
 * @param id
 * @return new tree data  纯函数
 */
function deleteTreeNode(origin, id, key = "id") {
    return origin.filter((node) => {
        if (node.children) {
            node.children = deleteTreeNode(node.children, id, key);
        }
        return node[key] !== id;
    });
}

exports.deleteTreeNode = deleteTreeNode;
